import React, { memo } from "react";

import { Pagination } from "antd";
import "./index.scss";

export default memo(function WYPagination(props) {
  const { currentPage = 1, total = 1, onPageChange } = props;

  // render function
  function itemRender(current, type, originalElement) {
    if (type === "prev") {
      return <button className="control prev"> &lt; 上一页</button>;
    }
    if (type === "next") {
      return <button className="control next">下一页 &gt;</button>;
    }
    return originalElement;
  }

  return (
    <div className="pagination-wrapper">
      <Pagination
        className="pagination"
        size="small"
        current={currentPage}
        defaultCurrent={1}
        total={total}
        pageSize={35}
        showSizeChanger={false}
        itemRender={itemRender}
        onChange={onPageChange}
      />
    </div>
  );
});
